package com.g4.shoppingback.mapper;

import com.g4.shoppingback.pojo.DdUsersInfo;
import com.g4.shoppingback.pojo.UserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
* <p>
    *  Mapper 接口
    * </p>
*
* @author admin
* @since 2022-02-19
*/
@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {

    /**
     * 新增角色和用户关系
     * @param userId
     * @param roleId
     * @return
     */
    @Insert("insert into user_role values(null,#{userId},#{roleId})")
    int addRole(@Param("userId") Integer userId,
                @Param("roleId") Integer roleId);

    /**
     * 删除角色和用户关系
     * @param userId
     * @return
     */
    @Delete("delete from user_role where user_id=#{userId};")
    int deleteRoleByUserId(Integer userId);

    /**
     * 修改角色和用户关系
     * @param userRole
     * @return 返回影响行数
     */
    int updateUserRole(UserRole userRole);
}
